module Prawn
  module MyHelpers

    def my_default_fonts
      nil
    end

    def my_logo_header
      image "#{Dir.pwd}/assets/images/brand.jpeg", :at => [0, bounds.top], :width => 120
      font_size(16) do
        draw_text "病理科病理诊断报告", :at => [200, bounds.top - 20], :width => 120
      end
      bounding_box([bounds.right - 120, bounds.top], :width => 120, :height => 50) do
        font "./assets/fonts/SimHei.ttf", :style => :bold, :size => 8
        text "呼和浩特新途医学检验所"
        text "电话: 0471-3591087"
        image "#{Dir.pwd}/assets/images/barcode.jpeg", :height => 12, :width => 100
        text "471-19-08549"
      end
    end

    def my_footer_with_address
      bounding_box([0, bounds.bottom + 130 ], :width => 550, :height => 130) do
        stroke_color "CCCCCC"
        stroke_horizontal_rule
        move_down 10
        draw_text "报告医生签名(签字盖章有效):", :at => [0, cursor]
        draw_text "谭建友,医学博士，理学博士", :at => [200, cursor]
        draw_text "审核医生签名(签字盖章有效):", :at => [400, cursor]
        move_down 10
        image "./assets/images/sign.jpeg", :position => :left, :scale => 0.4
        draw_text "持美国纽约州行医执照，美国病理协会", :at => [200, cursor + 30]
        draw_text "认证病理医师，在中国注册", :at => [200, cursor + 20]
        draw_text "Jianyou Tan, M.D.,Ph.D. Licensed Physician in New York State, Diplomate of American", :at => [200, cursor + 10]
        draw_text "Board of Pathology in Anatomic/Clinical Pathology and Dermatopathology", :at => [200, cursor]
        move_down 10
        image "./assets/images/qrcode.jpeg", :position => :right, :scale => 0.1
        draw_text "美国新途总部: NewPath Diagnostics, 42-11 Parsons Boulevard, Flushing, NY 11355, U.S.A.", :at => [0, cursor + 30]
        # move_down 10
        draw_text "Tel: (718)321-1108 Fax: (718)321-0158 Website: www.newpathdx.com CLIA#:33D1093401 CAP#:7223373", :at => [0, cursor + 20]
        draw_text "新途中国北方中心:内蒙古自治区呼和浩特市回民区新华大街82号一楼 (内蒙古医科大学附属医院新门诊大楼对面大统体育西巷)", :at => [0, cursor + 10]
        move_down 5
        text "本报告只对此标本负责。如有疑问请与本实验室联系。"
      end
    end

    def my_page_numbers(string = "", options={})
      string = "page <page> of <total>" if string.empty?
      options = { :at => [bounds.right - 112, -60],
                  :width => 100,
                  :align => :right,
                  :start_count_at => 1,
                  :color => "333333",
                  :size => 8  }.merge(options)

      number_pages string, options
    end

  end
end
